import { defHttp } from '/@/utils/http/axios';
import { UploadApiResult } from '/@/api/sys/model/uploadModel';
import { UploadFileParams } from '/#/axios';
/**
 * 下载文件 用于excel导出
 * @param url
 * @param parameter
 * @returns {*}
 */
export function downFile(url) {
  return defHttp.request({
    url: url,
    method: 'get',
    responseType: 'blob',
    // timeout: 300000,
  });
}

export function uploadFile(
  url,
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) {
  return defHttp.uploadFile<UploadApiResult>(
    {
      url,
      onUploadProgress,
    },
    params,
  );
}

export function uploadAction(url, parameter) {
  return defHttp.request({
    url: url,
    params: parameter,
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
}
